package com.wh.minio;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
    //MinIO的IP地址+端口.
    private String endpoint;
    //accessKey类似于用户ID，用于唯一标识你的账户
    private String accessKey;
    //secretKey是你账户的密码
    private String secretKey;
    //默认存储桶名称
    private String bucketName;

    /**
     * 获取Minio链接客户端
     * @return
     */
    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient =
                MinioClient.builder()
                        .endpoint(endpoint)
                        .credentials(accessKey, secretKey)
                        .build();
        return minioClient;
    }
}